<!DOCTYPE HTML>
<%@page import="shop.vo.UserBean"%>
<%@page import="shop.vo.ProTypeBean"%>
<%@page import="java.util.Iterator"%>
<%@page import="shop.vo.ProductBean"%>
<%@page import="java.util.List"%>
<%@page import="shop.factory.*"%>
<html>
<head>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../css/head.css" />
<link rel="stylesheet" type="text/css" href="../css/foot.css" />
<link rel="stylesheet" type="text/css" href="css/productList.css" />
<link rel="stylesheet" type="text/css" href="css/tab.css" />
<script src="../js/jquery-1.10.2.min.js" type="text/javascript"
	charset="utf-8"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jq.js" type="text/javascript" charset="utf-8"></script>

<!--<meta name="viewport" content="width=device-width, initial-scale=1">-->
<!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
<title>商品查看页面</title>
</head>
<%
	String str5 = (String)session.getAttribute("user");
	UserBean user = new UserBean();
	user.setUser_name(str5);
	int id = DAOFactory.getIUserDAOInstance().findId(user);
	String title = (String)session.getAttribute("title");
	String keyWord = (String)session.getAttribute("keyWord");
	int nowPage = 1;
	int pageSize = 10;
	String str = request.getParameter("to");
	if (str != null) {
		nowPage = Integer.parseInt(str);
	}
	int up = nowPage;
	int next = nowPage;
	int maxPage = 0;
	int count = 0;
	if (title.equals("全部")) {
		count = DAOFactory.getIProductDAOInstance().getCount();
	}else if (title.equals("搜索")) {
		count = DAOFactory.getIProductDAOInstance().getCount(keyWord);
	}else {
		ProTypeBean ptype = new ProTypeBean();
		ptype.setPtype_name(title);
		int i = DAOFactory.getIProTypeDAOInstance().find(ptype);
		count = DAOFactory.getIProductDAOInstance().getCount(i);
	}
	if (count % pageSize == 0) {
		maxPage = count / pageSize;
	} else {
		maxPage = (count / pageSize) + 1;
	}
	if (next < maxPage) {
		next += 1;
	}
	if (up > 1) {
		up -= 1;
	}
	List<ProductBean> list = null;
	if (title.equals("全部")) {
		list = DAOFactory.getIProductDAOInstance().list(nowPage, pageSize);
	}else if (title.equals("搜索")) {
		list = DAOFactory.getIProductDAOInstance().find(keyWord, nowPage, pageSize);
	}else {
		ProductBean product = (ProductBean)session.getAttribute("pro1");
		list = DAOFactory.getIProductDAOInstance().list(product, nowPage, pageSize);
	}
%>
<body>
	<nav class="navbar navbar-default" role="navigation">
		<div class="navbar-header">
			<button type="button" class="navbar-toggle" data-toggle="collapse"
				data-target="#bs-example-navbar-collapse-1">
				<span class="sr-only">Toggle navigation</span> <span
					class="icon-bar"></span> <span class="icon-bar"></span> <span
					class="icon-bar"></span>
			</button>
		</div>
		<div class="collapse navbar-collapse"
			id="bs-example-navbar-collapse-1">
			<ul class="nav navbar-nav">
				<li class="active"><a href="../index.jsp">首页</a></li>
				<li><a href="<%=request.getContextPath() %>/OrderServlet?action=MyOrder"> <img src="../images/order.png" /> 我的订单
				</a></li>
				<li></li>
				<li><a href="<%=request.getContextPath() %>/OrderServlet?action=MyCart"> <img src="../images/car.png" /> 我的购物车
				</a></li>
				<li><a href="<%=request.getContextPath() %>/FavoriteServlet?action=MyFav"> <img src="../images/favorite.png" /> 我的收藏
				</a></li>
				<li><a href="<%=request.getContextPath() %>/AddressServlet?action=MyAddress"> <img src="../images/address.png" /> 我的地址簿
				</a></li>
			</ul>
			<ul class="nav navbar-nav navbar-right">
				<li><a href="<%=request.getContextPath() %>/UserServlet?action=xinxi"><span id="huanying">欢迎光临，游客</span></a></li>
				<li><a href="../Login/login.jsp">登陆</a></li>
				<li><a href="../Login/regist.jsp">注册</a></li>
				<li><a href="<%=request.getContextPath() %>/UserServlet?action=logout" class="active" onclick="return confirm('确认退出?')">退出</a></li>
			</ul>
		</div>
	</nav>
	<div class="container">
		<div class="row">
			<div class="col-lg-6">
				<img src="../images/logo.png" /> <span>只有你想不到，没有你买不到</span>
			</div>
			<div class="col-lg-6">
				<ul>
					<li><img src="../images/HEADERVIP1_gxf.png" /></li>
					<li><img src="../images/HEADERVIP2_k3d.png" /></li>
					<li><img src="../images/HEADERVIP3_wzf.png" /></li>
				</ul>
				<div class="mag_position">
					<img src="../images/quality.png" />
				</div>
			</div>
		</div>
	</div>

	<!--导航开始-->
	<div class="container-fluid nav-bg">
		<div class="navbar-default navbar-wrapper"
			id="bs-example-navbar-collapse-1">
			<div class=" navbar-header">
				<div class="container">
					<ul class="nav nav-pills" id="textcolor">
						<li class="active"><a href="../index.jsp">首页</a></li>
						<%
							List<Integer> list4 = DAOFactory.getIProTypeDAOInstance().listType();
							Iterator<Integer> it4 = list4.iterator();
							while (it4.hasNext()) {
								int b = it4.next();
								ProTypeBean ptype4 = DAOFactory.getIProTypeDAOInstance().find(b);
						%>
						<li><a href="<%=request.getContextPath()%>/ProductServlet?action=list&str=<%=ptype4.getPtype_name()%>"><%=ptype4.getPtype_name()%>专卖</a></li>
						<%
							}
						%>
					</ul>
				</div>
			</div>
		</div>
	</div>
	<!--导航结束-->

	<div class="container">
		<div class="col-lg-12">
			<form action="<%=request.getContextPath() %>/ProductServlet" method="post">
				<div id="textinput">
					<input type="text" name="reserch" id="reserch" placeholder="名称搜素 " />
				</div>
				<input type="submit" value="搜索" class="btn btn-danger" id="buttom" />
				<input type="hidden" name="action" value="serch">
			</form>
		</div>
		
		<div class="col-md-12 position-weizhi">
			<p>
				当前位置>><span id="title"><%=title %></span>
			</p>
		</div>
		<!--图片开始-->
		<div class="row rowmagin">
			<%
				Iterator<ProductBean> it = list.iterator();
				while (it.hasNext()) {
					ProductBean product1 = it.next();
			%>
			
			<div class="col-sm-6 col-md-3">
				<a href="<%=request.getContextPath()%>/ProductServlet?action=xiangqing&proId=<%=product1.getPro_id() %>" class="thumbnail"> <img
					src="../<%=product1.getPro_litlleimg() %>" alt="...">
				</a>
				<div class="price">
					<span id="yuan"><i>￥</i><%=product1.getPrice()%></span>
				</div>
				<div>
					<span id="pro"> <a href="<%=request.getContextPath()%>/ProductServlet?action=xiangqing&proId=<%=product1.getPro_id() %>"><%=product1.getPro_name() %></a>
					</span>
				</div>
			</div>
			<%
				}
			%>
		</div>
		<!--图片结束-->
		<div id="page">
			<span id="pagenumber"> 总共<b style="color: #C9302C;"><%=maxPage %></b>页&nbsp;&nbsp;当前是第<b
				style="color: #C9302C;"><%=nowPage %></b>页
			</span> <span id="last"> <a href="productList.jsp?to=<%=up%>">上一页</a>
			</span> <span id="next"> <a href="productList.jsp?to=<%=next%>">下一页</a>
			</span>
		</div>
	</div>


	<!--尾部开始-->
	<div class="container-fluid container-bg">
		<div class="row">
			<div class="col-md-3 foot-img">
				<img src="../images/logo.png" class="image_logo" />
			</div>
			<div class="col-md-3">
				<h4 class="page-header">我们的宗旨</h4>
				<p class="foot-word">把第一次购买的顾客变成终身顾客</p>
				<p class="foot-word">服务比销售更重要</p>
				<p class="foot-word">服务大众 诚信网商</p>
			</div>
			<div class="col-md-3">
				<h4 class="page-header">售后服务</h4>
				<p class="foot-word">
					<img src="../images/phone.png" />电话投诉：110
				</p>
				<p>
					<a href="#" class="btn btn-primary btn-success" data-toggle="modal"
						data-target="#myModal">客户反馈</a>
				</p>
			</div>
			<div class="col-md-3">
				<h4 class="page-header">联系我们</h4>
				<p class="foot-word">
					<img src="../images/QQ.png" />QQ：118283513、102358974
				</p>
				<p class="foot-word">
					<img src="../images/phone.png" />电联：0668-8717664
				</p>
				<p class="foot-word">
					<img src="../images/weixin.png" />微信号：LH12150603
				</p>
			</div>
			<div class="col-lg-12 text-center">
				<p>
					友情链接：<a href="http://www.taobao.com">淘宝</a> <a
						href="http://www.tmall.com/">天猫</a> <a href="http://www.vip.com/">唯品会
					</a><a href="http://www.jd.com/">京东</a> <a
						href="http://www.paipai.com/">拍拍网</a> <a
						href="http://www.mogujie.com/">蘑菇街</a> <br /> Power by Liang&Luo
					@版本号V0.0.01
				</p>
			</div>
		</div>
	</div>

	<div class="modal fade" id="myModal" tabindex="1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true"
		style="z-index: 9999;">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h3 class="page-header font_style" id="myModalLabel">请留下您宝贵的意见\(^o^)/~</h3>
				</div>
				<div class="modal-body">
					<form action="<%=request.getContextPath() %>/MessageServlet?userId=<%=id %>" method="post">
						<textarea class="form-control" rows="3 " name="message"></textarea>
						<div class="modal-footer">
							<input class="btn btn-primary" type="submit" value="留言" />
							<input type="hidden" name="action" value="addMessage">
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
	<!--尾部结束-->
</body>
<script type="text/javascript">
<%
	String str0 = (String)session.getAttribute("user");
	if (session.getAttribute("user") != null) {
%>
document.getElementById("huanying").innerHTML = "欢迎光临，<%=str0%>";
<%
	} else {
%>
document.getElementById("huanying").innerHTML = "欢迎光临，游客";
<%
	}
%>
</script>
</html>